#ifndef USERONLINE_H
#define USERONLINE_H
#include "BaseEntity.h"
class UserOnline : public BaseEntity{
public:
    QString tokenId;
    QString deptName;
    QString userName;
    QString ipaddr;
    QString loginLocation;
    QString browser;
    QString os;
    qlonglong loginTime;
    QJsonObject toJson() const {
        QJsonObject obj;
        obj["tokenId"] = tokenId;
        obj["deptName"] = deptName;
        obj["userName"] = userName;
        obj["ipaddr"] = ipaddr;
        obj["loginLocation"] = loginLocation;
        obj["browser"] = browser;
        obj["os"] = os;
        obj["loginTime"] = QString::number(loginTime);
        obj["searchValue"] = searchValue;
        obj["createBy"] = createBy;
        obj["createTime"] = createTime;
        obj["updateBy"] = updateBy;
        obj["updateTime"] = updateTime;
        obj["remark"] = remark;
        return obj;
    }

    static UserOnline toUserOnline(const QJsonObject &obj) {
        UserOnline userOnline;
        userOnline.tokenId = obj["tokenId"].toString();
        userOnline.deptName = obj["deptName"].toString();
        userOnline.userName = obj["userName"].toString();
        userOnline.ipaddr = obj["ipaddr"].toString();
        userOnline.loginLocation = obj["loginLocation"].toString();
        userOnline.browser = obj["browser"].toString();
        userOnline.os = obj["os"].toString();
        userOnline.loginTime = obj["loginTime"].toVariant().toLongLong();
        userOnline.searchValue = obj["searchValue"].toString();
        userOnline.createBy = obj["createBy"].toString();
        userOnline.createTime = obj["createTime"].toString();
        userOnline.updateBy = obj["updateBy"].toString();
        userOnline.updateTime = obj["updateTime"].toString();
        userOnline.remark = obj["remark"].toString();
        return userOnline;
    }
};

#endif // USERONLINE_H
